<template>
  <div class="w">
    <div class="tab_box_order" @click="onClick" duration="0" replace="true">
      <van-tabs v-model="active" >
        <van-tab  title="全部" to="/order?id=all"></van-tab>
        <van-tab  title="待付款" to="/order?id=0"></van-tab>
        <van-tab  title="待发货" to="/order?id=1"></van-tab>
        <van-tab  title="待收货" to="/order?id=2"></van-tab> 
        <van-tab  title="已完成" to="/order?id=3"></van-tab>
        <van-tab  title="已取消" to="/order?id=4"></van-tab>
      </van-tabs>
      <!-- <div>
        <a href="">全部</a>
        <a href="">待付款</a>
        <a href="">待发货</a>
        <a href="">待收货</a>
        <a href=""></a>

      </div> -->
    </div>
    <div>
      <All :para="para"></All>
    </div>
  </div>
</template>

<style lang="" >
  /* .tab_box_order{
    margin-bottom: 0.65rem;
  } */
  /* .van-tabs__wrap--scrollable .van-tab{
    flex-basis: 20% !important;
  } */
  /* .van-tabs__wrap--scrollable .van-tab { */
    /* -webkit-box-flex: 0;
    -webkit-flex: 0 0 22%;
    flex: 0 0 22%; */
    /* flex-basis: 20% !important; */
/* } */

</style>
<script>
  import All from "./all.vue"
  import { Tab, Tabs } from 'vant';
  export default{
    data () {
      return {
        active: 0,//选中的标签
        prevactive:0,//上一次选中的标签
        para:{},//传递给子组件的参数
        //flag:false,
      }
    },
    mounted() {
      var id=this.$route.query.id;
      console.log(id,this.active);
      switch(id){
        case "all":
            this.active=0;
            this.prevactive=0;
            this.para.id="all";
            this.para.type=0;
            this.para.flag=false;
            break;
        case '0':
            this.active=1;
            this. prevactive=1;
            this.para.id=0;
            this.para.type=1;
            this.para.flag=false;
            break;
        case '1':
            this.active=2;
            this. prevactive=2;
            this.para.id=1;
            this.para.type=2;
            this.para.flag=false;
            //console.log(this.active,3636);
            break;
        case '2':
            this.active=3;
            this. prevactive=3;
            this.para.id=2;
            this.para.type=3;
            this.para.flag=false;
            break;
        case '3':
            this.active=4;
            this. prevactive=4;
            this.para.id=3;
            this.para.type=4;
            this.para.flag=false;
            break;
        case '4':
            this.active=5;
            this. prevactive=5;
            this.para.id=4;
            this.para.type=5;
            this.para.flag=false;
            break;
        default:
            break;

      };
      console.log(id,this.active);

    },
    components: {
      All
    },
    watch: {
    //   '$route' (to, from) {
    // this.$router.go(0);
    // }
  },
    methods: {
    onClick(name, title) {
      this.para.flag=true;
      //this.$router.go(0);
      //Toast(title);
      //console.log(name,3333)
    //  if(this.active==this.prevactive){
    //       this.active=this.prevactive
    //      return false
    //  };
    //   console.log(this.active,"这是选中的");
    //   switch(this.active){
    //     case 0:
    //         //this.para="all";//全部     
    //         //this.$router.push("/order?id="+"all") ;
    //         this.$router.push({path:'/order',params:{id:'all'}})
    //         break;
    //     case 1:
    //         //this.para=0;//待支付
    //         //this.$router.push("/order?id="+0) ;
    //         this.$router.push({path:'/order',params:{id:'0'}})
    //         break;
    //     case 2:
    //         //this.para=1;//代发货
    //         //this.$router.push("/order?id="+1) ;
    //         this.$router.push({path:'/order',params:{id:'1'}})
    //         break;
    //     case 3:
    //         //this.para=2;//待收货;
    //         //this.$router.push("/order?id="+2) ;
    //         this.$router.push({path:'/order',params:{id:'2'}})
    //         break;
    //     case 4:
    //         //this.para=3;//已完成
    //         //this.$router.push("/order?id="+3) ;
    //         this.$router.push({path:'/order',params:{id:'3'}})
    //         break;
    //     case 5:
    //        //this.para=4;//已取消
    //        //this.$router.push("/order?id="+4) ;
    //        this.$router.push({path:'/order',params:{id:'4'}})
    //         break;
    //     default:
    //       break;

    //   };
    //   //this.prevactive=this.active;
    //   //console.log(this.para,"这是要传递的参数")

    },
  },

  }
</script>